//
//  TogetherDetail_MeJoinViewController.m
//  hello
//
//  Created by 查传申 on 15/12/10.
//  Copyright © 2015年 查传申. All rights reserved.
//

#import "TogetherDetail_MeJoinViewController.h"
#import "Headbutton.h"
#import "HeadNeedTableViewCell.h"
#import "HeadTableViewCell.h"
@interface TogetherDetail_MeJoinViewController ()
@property(nonatomic,strong)UILabel *label_need;
@property(nonatomic,strong)UILabel *lable_join;
@end

@implementation TogetherDetail_MeJoinViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self loadHead_subviews];
    self.arr_large = [[NSMutableArray alloc]initWithObjects:@"",@"", nil];
        self.arr_material = [[NSMutableArray alloc]initWithObjects:@"",@"",@"",@"",@"", nil];
    self.arr_small = [[NSMutableArray alloc]initWithObjects:@"",@"",@"",@"",@"查看全部",@"查看发布方公益项目记录", nil];
    [self tableview_frameLoad];
   
}
-(void)loadHead_subviews{
    self.backgroundView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width - 20, 1830)];
    _backgroundView.backgroundColor = [UIColor cyanColor];
    UIImageView *imageView_logo = [[UIImageView alloc]initWithFrame:CGRectMake(0, 5, 50, 50)];
    imageView_logo.backgroundColor = [UIColor brownColor];
    [_backgroundView addSubview:imageView_logo];
    
    UILabel *label_title = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x + imageView_logo.frame.size.width + 5, imageView_logo.frame.origin.y, _backgroundView.frame.size.width - imageView_logo.frame.size.width -imageView_logo.frame.origin.x, imageView_logo.frame.size.height/2)];
    label_title.backgroundColor = [UIColor redColor];
    [_backgroundView addSubview:label_title];
    
    UILabel *label_type = [[UILabel alloc]initWithFrame:CGRectMake(label_title.frame.origin.x, label_title.frame.origin.y + label_title.frame.size.height, _backgroundView.frame.size.width/3, label_title.frame.size.height)];
    label_type.backgroundColor = [UIColor greenColor];
    [_backgroundView addSubview:label_type];
    
    UILabel *label_time = [[UILabel alloc]initWithFrame:CGRectMake(label_type.frame.size.width + label_type.frame.origin.x + 10, label_type.frame.origin.y, _backgroundView.frame.size.width/3, label_type.frame.size.height)];
    label_time.backgroundColor = [UIColor purpleColor];
    [_backgroundView addSubview:label_time];
    
    UIImageView *imageView_photo = [[UIImageView alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, imageView_logo.frame.origin.y  +imageView_logo.frame.size.height + 10, _backgroundView.frame.size.width, 150)];
    imageView_photo.backgroundColor = [UIColor greenColor];
    [_backgroundView addSubview:imageView_photo];
    
    UILabel *label_detail_title = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, imageView_photo.frame.size.height + imageView_photo.frame.origin.y  +10, 60, 30)];
    label_detail_title.backgroundColor = [UIColor redColor];
    label_detail_title.text = @"项目详情";
    [_backgroundView addSubview:label_detail_title];
    
    UILabel *label_detail = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_detail_title.frame.size.height + label_detail_title.frame.origin.y  +10, _backgroundView.frame.size.width , 100)];
    label_detail.backgroundColor = [UIColor redColor];

    [_backgroundView addSubview:label_detail];
    
    UIImageView *imageView_material = [[UIImageView alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_detail.frame.size.height + label_detail.frame.origin.y  +10, _backgroundView.frame.size.width, 150)];
    imageView_material.backgroundColor = [UIColor greenColor];
    [_backgroundView addSubview:imageView_material];
    
    UILabel *label_money = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, imageView_material.frame.origin.y + imageView_material.frame.size.height +10, _backgroundView.frame.size.width, 30)];
    label_money.text = @"项目投入";
    label_money.backgroundColor = [UIColor redColor];
    [_backgroundView addSubview:label_money];
    
    UILabel *label_step = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_money.frame.origin.y + label_money.frame.size.height +10, _backgroundView.frame.size.width, 30)];
    label_step.text = @"项目计划实施阶段";
    label_step.backgroundColor = [UIColor redColor];
    [_backgroundView addSubview:label_step];
    NSArray *arr = [[NSArray alloc]initWithObjects:@"启动",@"初期",@"中期",@"后期",@"结束", nil];
    for (int i = 0; i <5; i++) {
        Headbutton *button = [[Headbutton alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_step.frame.origin.y  +label_step.frame.size.height  +10 +i*35, _backgroundView.frame.size.width, 30)];
        [button setTitle:@"" forState:UIControlStateNormal];
        button.label_tip.text = [arr objectAtIndex:i];
        button.tag = 1210 + i;
        [button addTarget:self action:@selector(button_head_Click) forControlEvents:UIControlEventTouchUpInside];
        button.backgroundColor = [UIColor yellowColor];
        [_backgroundView addSubview:button];
        
    }
    UILabel *label_activity_type = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_step.frame.origin.y + label_step.frame.size.height + 35*5, _backgroundView.frame.size.width/2, 30)];
    label_activity_type.text = @"项目活动方式";
    label_activity_type.backgroundColor = [UIColor brownColor];
    [_backgroundView addSubview:label_activity_type];
    
    UILabel *label_activity_value = [[UILabel alloc]initWithFrame:CGRectMake(_backgroundView.frame.size.width/2, label_activity_type.frame.origin.y, label_activity_type.frame.size.width, label_activity_type.frame.size.height)];
    label_activity_value.backgroundColor = [UIColor greenColor];
    [_backgroundView addSubview:label_activity_value];
    
    UILabel *label_activity_area = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_activity_type.frame.origin.y + label_activity_type.frame.size.height+10, _backgroundView.frame.size.width/2, 30)];
    label_activity_area.text = @"项目活动区域";
    label_activity_area.backgroundColor = [UIColor brownColor];
    [_backgroundView addSubview:label_activity_area];
    
    UILabel *label_activity_area_value = [[UILabel alloc]initWithFrame:CGRectMake(_backgroundView.frame.size.width/2, label_activity_area.frame.origin.y, label_activity_area.frame.size.width, label_activity_area.frame.size.height)];
    label_activity_area_value.backgroundColor = [UIColor greenColor];
    [_backgroundView addSubview:label_activity_area_value];

    self.label_need = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_activity_area_value.frame.size.height + label_activity_area_value.frame.origin.y + 10, _backgroundView.frame.size.width, 30)];
    _label_need.text = @"项目合作需求";
    _label_need.backgroundColor = [UIColor purpleColor];
    [_backgroundView addSubview:_label_need];
    [self tableview_material_FrameLoad];
    
    UILabel *label_stop_tip = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, _tableView_material.frame.size.height + _tableView_material.frame.origin.y + 10, _backgroundView.frame.size.width/2, 30)];
    label_stop_tip.text = @"距离招募截止:";
    label_stop_tip.backgroundColor = [UIColor blueColor];
    [_backgroundView addSubview:label_stop_tip];
   
    UILabel *label_stop_value = [[UILabel alloc]initWithFrame:CGRectMake(_backgroundView.frame.size.width/2,  label_stop_tip.frame.origin.y, _backgroundView.frame.size.width/2, 30)];
    label_stop_value.backgroundColor = [UIColor lightGrayColor];
    [_backgroundView addSubview:label_stop_value];

    
    UILabel *label_money_collect = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_stop_tip.frame.size.height + label_stop_tip.frame.origin.y + 10, _backgroundView.frame.size.width/2, 30)];
    label_money_collect.text = @"已募集资金";
    label_money_collect.backgroundColor = [UIColor blueColor];
    [_backgroundView addSubview:label_money_collect];

    
    UILabel *label_money_value = [[UILabel alloc]initWithFrame:CGRectMake(_backgroundView.frame.size.width/2,  label_money_collect.frame.origin.y, _backgroundView.frame.size.width/2, 30)];

    label_money_value.backgroundColor = [UIColor lightGrayColor];
    [_backgroundView addSubview:label_money_value];

    UILabel *label_consult = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_money_collect.frame.origin.y + label_money_collect.frame.size.height + 10, _backgroundView.frame.size.width, 30)];
    label_consult.text = @"联系人";
    label_consult.backgroundColor = [UIColor redColor];
    [_backgroundView addSubview:label_consult];
    
    UILabel *label_phone = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_consult.frame.origin.y + label_consult.frame.size.height + 10, _backgroundView.frame.size.width, 30)];
    label_phone.text = @"联系方式";
    label_phone.backgroundColor = [UIColor redColor];
    [_backgroundView addSubview:label_phone];

    UILabel *label_project = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, label_phone.frame.origin.y  +label_phone.frame.size.height + 10, label_phone.frame.size.width, 30)];
    label_project.text = @"项目进程";
    label_project.backgroundColor = [UIColor greenColor];
    [_backgroundView addSubview:label_project];
    
    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(5, label_project.frame.size.height + label_project.frame.origin.y  +10, _backgroundView.frame.size.width - 10, 4)];
    line.backgroundColor = [UIColor lightGrayColor];
    [_backgroundView addSubview:line];
    NSArray *arr_step =[[NSArray alloc]initWithObjects:@"招募",@"启动",@"初期",@"中期",@"后期",@"结束", nil];
    for (int i = 0; i < 6; i++) {
        UIImageView *image_point = [[UIImageView alloc]initWithFrame:CGRectMake(line.frame.size.width/5 *i -5, -3, 10, 10)];
        image_point.clipsToBounds = YES;
        image_point.layer.cornerRadius = 5;
        image_point.backgroundColor = [UIColor lightGrayColor];
    
        UILabel *label_step = [[UILabel alloc]init];
        label_step.frame = CGRectMake(line.frame.size.width/5 *i -10, line.frame.size.height +line.frame.origin.y+ 10, 30, 20);
        if (i==0) {
            label_step.frame =CGRectMake(line.frame.size.width/5 *i, line.frame.size.height +line.frame.origin.y+ 10, 30, 20);
        }if (i == 5) {
            label_step.frame =CGRectMake(_backgroundView.frame.size.width - 30, line.frame.size.height +line.frame.origin.y+ 10, 30, 20);
        }
       
        if (i <1) {
            UIView *viewcolor = [[UIView alloc]initWithFrame:CGRectMake(0, 0,line.frame.size.width/5-5, line.frame.size.height)];
            viewcolor.backgroundColor = [UIColor brownColor];
            [line addSubview:viewcolor];
            image_point.backgroundColor = [UIColor brownColor];
        }
        label_step.text = arr_step[i];
        label_step.font = [UIFont systemFontOfSize:14];
        label_step.backgroundColor = [UIColor redColor];
        [_backgroundView addSubview:label_step];
        [line addSubview:image_point];
    }
     self.lable_join  = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, line.frame.size.height  +line.frame.origin.y +40, _backgroundView.frame.size.width/2, 30)];
    _lable_join.backgroundColor = [UIColor redColor];
    _lable_join.text = @"项目参与者(100)";
    [_backgroundView addSubview:_lable_join];
    [self tableViewSmall_frameLoad];
    
    UILabel *lable_seecount = [[UILabel alloc]initWithFrame:CGRectMake(imageView_logo.frame.origin.x, _tableView_small.frame.size.height  +_tableView_small.frame.origin.y, _backgroundView.frame.size.width/3 -10, 30)];
    lable_seecount.backgroundColor = [UIColor greenColor];
    [_backgroundView addSubview:lable_seecount];
    
    UIButton *button_image = [UIButton buttonWithType:UIButtonTypeCustom];
    button_image.frame = CGRectMake(_backgroundView.frame.size.width/3,lable_seecount.frame.origin.y, 30, 30);
    [button_image setImage:nil forState:UIControlStateNormal];
    [button_image addTarget:self action:@selector(button_image) forControlEvents:UIControlEventTouchUpInside];
    button_image.backgroundColor = [UIColor lightGrayColor];
    [_backgroundView addSubview:button_image];
    

    UILabel *lable_zan = [[UILabel alloc]initWithFrame:CGRectMake(button_image.frame.origin.x + button_image.frame.size.width, button_image.frame.origin.y, _backgroundView.frame.size.width/3, 30)];
    lable_zan.backgroundColor = [UIColor blueColor];
    [_backgroundView addSubview:lable_zan];

    UIButton *button_comment_all= [UIButton buttonWithType:UIButtonTypeCustom];
    button_comment_all.frame = CGRectMake(lable_seecount.frame.origin.x,lable_seecount.frame.origin.y+lable_seecount.frame.size.height + 10, _backgroundView.frame.size.width/2, 30);
    [button_comment_all setTitle:@"全部评论()" forState:UIControlStateNormal];
    [button_comment_all addTarget:self action:@selector(button_comment:) forControlEvents:UIControlEventTouchUpInside];
    button_comment_all.backgroundColor = [UIColor redColor];
    [_backgroundView addSubview:button_comment_all];
   
    UIButton *button_comment_me = [UIButton buttonWithType:UIButtonTypeCustom];
    button_comment_me.frame = CGRectMake(_backgroundView.frame.size.width/2,button_comment_all.frame.origin.y, _backgroundView.frame.size.width/2, 30);
    [button_comment_me setTitle:@"我的评论()" forState:UIControlStateNormal];
    [button_comment_me addTarget:self action:@selector(button_comment:) forControlEvents:UIControlEventTouchUpInside];
    button_comment_me.backgroundColor = [UIColor blueColor];
    [_backgroundView addSubview:button_comment_me];
}
-(void)tableViewSmall_frameLoad{
    self.tableView_small = [[UITableView alloc]initWithFrame:CGRectMake(0, _lable_join.frame.size.height + _lable_join.frame.origin.y + 10, _backgroundView.frame.size.width, 270) style:UITableViewStylePlain];
    _tableView_small.scrollEnabled = NO;
    _tableView_small.dataSource = self;
    _tableView_small.delegate = self;
    [_tableView_small registerClass:[HeadTableViewCell class] forCellReuseIdentifier:@"reuse2"];
    [_tableView_small registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuse3"];

    [_backgroundView addSubview:_tableView_small];
}
-(void)tableview_material_FrameLoad{
    self.tableView_material =[[UITableView alloc]initWithFrame:CGRectMake(0, _label_need.frame.size.height + _label_need.frame.origin.y  +10, _backgroundView.frame.size.width , 300) style:UITableViewStylePlain];
    _tableView_material.delegate = self;
    _tableView_material.dataSource = self;
    _tableView_material.scrollEnabled  =NO;
    [_tableView_material registerClass:[HeadNeedTableViewCell class] forCellReuseIdentifier:@"reuse1"];
    [_backgroundView addSubview:_tableView_material];
    
}
-(void)tableview_frameLoad{
    self.tableView_large = [[UITableView alloc]initWithFrame:CGRectMake(10, 0, self.view.frame.size.width - 20, self.view.frame.size.height - 64) style:UITableViewStylePlain];
    _tableView_large.delegate = self;
    _tableView_large.dataSource = self;
    [self tableView_headerView_frameLoad];
    [_tableView_large registerClass:[UITableViewCell class] forCellReuseIdentifier:@"reuse"];
    [self.view addSubview:_tableView_large];
}
-(void)tableView_headerView_frameLoad{
    _tableView_large.tableHeaderView = _backgroundView;
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    if (tableView == _tableView_material) {
        return _arr_material.count;
    }
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (_tableView_large == tableView) {
        return _arr_large.count;
        
    }else if (tableView == _tableView_material){
        return 1;
    }
    return _arr_small.count;
    
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (tableView == _tableView_large) {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse"];
        cell.textLabel.text = @"hello";
    return cell;
    }else if(tableView == _tableView_material){
        HeadNeedTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse1"];
        cell.label_title.text = @"15000";
        return cell;
    }
    HeadTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse2"];
    cell.label_name.text = @"haihao";
    if (indexPath.row >3) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"reuse3"];
        cell.textLabel.text = [_arr_small objectAtIndex:indexPath.row];
        return cell;
    }
    return cell;
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (tableView == _tableView_material) {
        return 20;
    }
    return 0;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (tableView == _tableView_material) {
        UIView *headSection = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 20)];
        headSection.backgroundColor = [UIColor lightGrayColor];
        UILabel *label_tip = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 20)];
        label_tip.text = @"资金";
        label_tip.backgroundColor = [UIColor purpleColor];
        [headSection addSubview:label_tip];
        
        UILabel *label_status = [[UILabel alloc]initWithFrame:CGRectMake(tableView.frame.size.width - 60 , 0, 60, 20)];
        label_status.text = @"已参与";
        label_status.backgroundColor = [UIColor brownColor];
        [headSection addSubview:label_status];
        return headSection;
    }
    return nil;
}
-(void)button_head_Click{
    NSLog(@"dfdsfsd");
}
-(void)button_image{
    NSLog(@"button");
}
-(void)button_comment:(UIButton *)button{
    NSLog(@"评论");
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
